package com.nzw.pojo.daydata;

import com.nzw.pojo.shift.ShiftDetail;

import javax.persistence.Column;
import javax.persistence.Table;
import java.text.DecimalFormat;
import java.util.Date;
import java.util.List;

/**
 * Created by Administrator on 2018/5/28/028.
 */



@Table(name = "t_daydata")
public class DayData {

    private Long id;
    private String date;
    private Double use98;
    private Double use95;
    private Double use92;
    private Double use90;
    private Double use0;
    private Double use_10;


    @Column(name = "id")
    public Long getId() {
        return id;
    }


    public void setId(Long id) {
        this.id = id;
    }

    @Column(name = "date")
    public String getDate() {
        return date;
    }

    public void setDate(String date) {
        this.date = date;
    }

    @Column(name = "use98")
    public Double getUse98() {
        return use98;
    }

    public void setUse98(Double use98) {
        this.use98 = use98;
    }

    @Column(name = "use95")
    public Double getUse95() {
        return use95;
    }

    public void setUse95(Double use95) {
        this.use95 = use95;
    }

    @Column(name = "use92")
    public Double getUse92() {
        return use92;
    }

    public void setUse92(Double use92) {
        this.use92 = use92;
    }

    @Column(name = "use90")
    public Double getUse90() {
        return use90;
    }

    public void setUse90(Double use90) {
        this.use90 = use90;
    }

    @Column(name = "use0")
    public Double getUse0() {
        return use0;
    }

    public void setUse0(Double use0) {
        this.use0 = use0;
    }

    @Column(name = "use_10")
    public Double getUse_10() {
        return use_10;
    }

    public void setUse_10(Double use_10) {
        this.use_10 = use_10;
    }


    public static DayData countList(List<ShiftDetail> list){

        DayData data = new DayData();

        double use_10 = 0;
        double use0 = 0;
        double use90 = 0;
        double use92 = 0;
        double use95 = 0;
        double use98 = 0;

        for(ShiftDetail  datail: list){
            if(datail.getOilCode().equals("0#")){
                use0 += datail.getOilNumber();
            }else if(datail.getOilCode().equals("-10#")){
                use_10 += datail.getOilNumber();
            }else if(datail.getOilCode().equals("90#")){
                use90 += datail.getOilNumber();
            }else if(datail.getOilCode().equals("92#")){
                use92 += datail.getOilNumber();
            }else if(datail.getOilCode().equals("95#")){
                use95 += datail.getOilNumber();
            }else if(datail.getOilCode().equals("98#")){
                use98 += datail.getOilNumber();
            }
        }

        DecimalFormat df = new DecimalFormat( "0.000 ");

        data.setUse0(Double.parseDouble(String.format("%.3f",use0)));
        data.setUse_10(Double.parseDouble(String.format("%.3f",use_10)));
        data.setUse90(Double.parseDouble(String.format("%.3f",use90)));
        data.setUse92(Double.parseDouble(String.format("%.3f",use92)));
        data.setUse95(Double.parseDouble(String.format("%.3f",use95)));
        data.setUse98(Double.parseDouble(String.format("%.3f",use98)));

        return data;







    }





}
